<?php

class MysqlConnector {

    //declaro properties
    private $_host;
    private $_user;
    private $_pass;
    private $_db;

    /**
     * puntero de conexión
     * @var type mySqli
     */
    private $_conn;

    /**
     * Los constructores se usan para inicializar las properties. Nada más!!!
     * @param type $pHost
     * @param type $pUser
     * @param type $pPass
     * @param type $pDb
     */
    public function __construct($pHost, $pUser, $pPass, $pDb) {
        //inicializar properties
        $this->_host = $pHost;
        $this->_user = $pUser;
        $this->_pass = $pPass;
        $this->_db = $pDb;
    }

    public function connect() {
        $this->_conn = new mysqli($this->_host, $this->_user, $this->_pass, $this->_db);
    }

    
    public function abmQuery($query) {
        $resultado = $this->_conn->query($query);
        echo "<pre>";        
        var_dump($resultado); 
        echo "</pre>";
        return true; //o false
    }
    /*
    public function customQuery($sql = "") {
        $resultado = $this->_conn->query($sql);
        $resultado->data_seek(0);
        while ($fila = $resultado->fetch_assoc()) {
            echo " id = " . $fila['id'] . " <pre>";
            print_r($fila);
            echo "</pre>";
        }
    }
     * 
     */

}

?>
